﻿using System.Threading;
using Cysharp.Threading.Tasks;
using Internal.KuiHuaBaoDian.Services.UI.Alert;
using KuiHuaBaoDian.Services.UGUI.Alert;

namespace KuiHuaBaoDian.Services.UGUI.Alert {

    public class AlertUIHandle : UIHandle, IAlertUIHandleInternal {

        public AlertService.ButtonFlag ClickedButtonFlag { get; private set; } = AlertService.ButtonFlag.None;

        void IAlertUIHandleInternal.SetButtonFlag(AlertService.ButtonFlag value) {
            ClickedButtonFlag = value;
        }

        public async UniTask<AlertService.ButtonFlag> WaitClickButton() {
            await KHBD.Context.WaitUntil(() => ClickedButtonFlag != AlertService.ButtonFlag.None, CancellationToken.None);
            return ClickedButtonFlag;
        }
    }
}

namespace Internal.KuiHuaBaoDian.Services.UI.Alert {

    public interface IAlertUIHandleInternal {

        void SetButtonFlag(AlertService.ButtonFlag value);
    }
}

